﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKGeometryFuncs;

namespace YJKRevitDimensionText.OneKeyPlanDim.DimesionDataEx
{
	public class GridInfoCacheCompare : IComparer<GridInfoCache>
	{
		public GridInfoCacheCompare(XYZ dirRef)
		{
			this.m_dirRef = dirRef;
		}

		public int Compare(GridInfoCache x, GridInfoCache y)
		{
			if (x == y)
			{
				return 0;
			}
			if (Geometry.Lessthan_Or_Equal((x.ThisGridLine.Origin - y.ThisGridLine.Origin).AngleTo(this.m_dirRef), Math.PI*.5))
			{
				return 1;
			}
			return -1;
		}

		private XYZ m_dirRef;
	}
}
